home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
BUS
/
TMCM Software and Labs.sit
/
Software for TMCM 7_95
/
Files for Lab 11
/
More Recursion Examples
/
C-curve
< prev
next >
Wrap
Text File
|
1993-11-03
|
2KB
|
69 lines
{ This programs difines a recrsive subroutine to
draw "C-curves". A C-curve is a path from A to
B that is formed by replacing straight line segments
with "detours" shaped (roughly) like a "C":
A C A
| -------
| |
| becomes |
| | D
| |
| |
| -------
B E B
The program also defines a subroutine TestC that
can be called to draw sample C-curves. TestC
is called once at the end of the program.
}
SUB C(distance,complexity)
IF complexity = 0 THEN
forward(distance)
ELSE
turn(-90)
C(distance/2, complexity-1)
turn(90)
C(distance/2, complexity-1)
C(distance/2, complexity-1)
turn(90)
C(distance/2, complexity-1)
turn(-90)
END IF
END SUB
SUB TestC
{ This subroutine can be called to draw sample C-curves;
the user is asked to specify the complexity and a
C-curve of that complexity is drawn stretch down most
of the screen. }
DECLARE complexity
penUp
MoveTo(3,4.5)
penDown
face(-90)
clear
AskUser("What level of complexity do you want (0 to 10)?", complexity)
complexity := trunc(complexity) { Make sure value is OK }
IF complexity < 0 THEN
complexity := 0
TellUser("Using complexity = 0.")
END IF
IF complexity > 10 THEN
complexity := 10
TellUser("Using complexity 10.")
END IF
C(9,complexity)
END SUB
TestC